package com.fxb.dubbo.quickstart;

import com.fxb.dubbo.quickstart.api.IProviderService;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;

/**
 * 服务消费者
 *
 * @author fangjiaxiaobai
 * @date 2021-10-13 16:20
 */
public class ConsumerApplication {

    private static final String zookeeperHost = "127.0.0.1";

    public static void main(String[] args) {
        ReferenceConfig<IProviderService> reference = new ReferenceConfig<>();
        reference.setApplication(new ApplicationConfig("first-dubbo-consumer"));
        reference.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181"));
        reference.setInterface(IProviderService.class);
        IProviderService service = reference.get();
        String message = service.sayHello();
        System.out.println(message);
    }
}
